<style>
.layui-body{
	z-index: unset;
}
.layui-form-item {
    clear: inherit;
}
.layui-upload-img {
    width: 92px;
    height: 92px;
    margin: 0 10px 10px 0;
}
</style>
<!-- 单图上传开始 -->
	<div class="layui-upload">
	  <button type="button" class="layui-btn" onclick="uploadSingle{$name}();">上传图片</button>
	</div> 
	
	<div class="layui-form"  id="singleUploadImage{$name}"  style="display:none;margin-top: 15px!important;">
	  <div class="layui-form-item">
		    <label class="layui-form-label">网络图片</label>
		    <div class="layui-input-inline">
		       <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请添加网络图片地址" class="layui-input" id="web_image{$name}">
		    </div>
		    <button type="button" class="layui-btn layui-btn-primary">提取</button>
	  </div>
	  <div class="layui-form-item">
		    <label class="layui-form-label">本地图片</label>
		    <div class="layui-upload">
				  <button type="button" class="layui-btn" id="single{$name}">上传图片</button>
				  <div class="layui-upload-list" >
				 		<label class="layui-form-label"></label>
					    <img class="layui-upload-img" id="{$name}SingleShowImage">
				  </div>
			</div> 
			<div class="layui-input-block">仅支持 gif、 jpeg、 png、 bmp 4种格式, 大小不超过3.0 MB</div>
	  </div>
	  <div class="nc-form-row">
	        <button type="button" class="layui-btn" id="btnSingle{$name}">提交</button>
	  </div>     
	</div>
	
<!-- 单图上传结束 -->

<script>
var index{$name};
	//单图
	function uploadSingle{$name}(){

			index{$name}=layer.open({
		  		  type: 1,
		  		  shadeClose: true,
		  		  shade: false,
		  		  area: ['700px'], //宽高
		  		  content:  $('#singleUploadImage{$name}'),
		  		  cancel: function(){ 
		  		    //右上角关闭回调
		  		    $("#singleUploadImage{$name}").hide();
		  		    //return false 开启该代码可禁止点击该按钮关闭
		  		  }
				});
	}
	
	layui.use('upload', function(){
		  var upload = layui.upload;
		//普通图片上传
		  var uploadInst = upload.render({
		    elem: '#single{$name}'
		    ,url: '{:addon_url("File://common/File/image")}'
		    ,auto: false
		    ,data: {}
			,bindAction: '#btnSingle{$name}'
		    ,choose: function(obj){
		      //预读本地文件示例，不支持ie8
		      obj.preview(function(index, file, result){
		        $('#{$name}SingleShowImage').attr('src', result); //图片链接（base64）
		      });
		    }
		    ,done: function(res){
		    	if(res.code > 0){
		    		$("#{$name}_image").attr("src", res.data.path);
		    		try{
		    			imageSingleCallBack(res,"{$name}");
		    		}catch(e){
		    			console.error("缺少回调函数imageSingleCallBack()");
		    		}
		    		layer.close(index{$name});
		    	}else{
		    		
		    	}
		      //如果上传失败
		      //上传成功
		    }
		    ,error: function(){
		      
		    }
		  });

	});
	
	/**
	*提取网络图片
	*/
	function pickup_image(){
		var web_image = $("#web_image{$name}").val();
	}
</script>